{% extends "./inc/base.html" %}
{% block content %}
<section class="vbox">
    <header class="header bg-light dk">
        <p>{{controller.meta_title}}</p>
    </header>
    <section class="scrollable wrapper">

        <section class="panel panel-default">
            <div class="search-form">
                <div class="row" style="padding:15px;">
                    <div class="col-sm-3">
                            <div class="input-group pull-right">
                                    <span class="input-group-addon">选择品类</span>
                                    <a style="width: 100%;" data-toggle="dropdown" class="btn btn-info btn-sm dropdown-toggle" type="button">{{dataMap[controller.get('pid')] or '全部'}}<span class="caret"></span></a>
                                    <ul style="width: 100%;" class="dropdown-menu">
                                        <li class="{%if not controller.get('pid') %}active{%endif%}">  <a href="/{{controller.active}}"
                                                class="text-info">全部</a></li>
                                        {% for select in dataSelect%}
                                        <li class="{%if controller.get('pid') == select.id %}active{%endif%}">  <a href="/{{controller.active}}?pid={{select.id}}"
                                            class="text-info">{{select.label}}</a></li>

                                        {% endfor %}
                                    </ul>
                                </div>
                    </div>
                    <div class="col-sm-3">
                        <div class="">
                            <a class="btn btn-sm btn-success ajax-post" style="width: 45%;" target-form="ids" href="/{{ctx.controller}}/active?status=1">
                                启用
                            </a>
                            <a class="btn btn-sm btn-danger ajax-post"  style="width: 45%;" target-form="ids" href="/{{ctx.controller}}/active?status=0">
                                停用
                            </a>
                        </div>
                    </div>
                    <div class="col-sm-3">
                        <span class="input-group-btn">
                            <a style="width: 100%;" class="btn  btn-default" type="button"
                                href="/{{ctx.controller}}/add" data-toggle="ajaxModal">新增物料</a>
                        </span>
                    </div>
                    <div class="col-sm-3">
                        <span class="input-group-btn">
                            <button style="width: 100%;" class="btn  btn-default" type="button" id="exportCSV"
                                url="/{{controller.active}}export?pid={{controller.get('pid')}}">导出</button>
                        </span>
                    </div>
                </div>
            </div>
            </div>
            <div class="table-responsive" style="position: relative;overflow: auto;width: 100%;">
                <table class="table table-hover b-t b-light" style="table-layout: fixed;">
                    <thead>
                        <tr>
                            <th style="width:20px;"><label class="checkbox m-n i-checks"><input type="checkbox"><i></i></label></th>
                            <th class="text-center">序号</th>
                            <th class="text-center">物料名称</th>
                            <th class="text-center">添加时间</th>
                            <th class="text-center">状态</th>
                        </tr>
                    </thead>
                    <tbody>
                        {% for item in list %}
                        <tr>
                            <td><label class="checkbox m-n i-checks"><input class="ids" type="checkbox" name="ids" value="{{item.id}}"><i></i></label></td>
                            <td class="text-center">{{loop.index}}</td>
                            <td class="text-center">{{item.label}}</td>
                            <td class="text-center">{{item.create_time|moment('YYYY-MM-DD HH:mm:ss')}}</td>
                            <td class="text-center">
                                <a href="/admin/material/setstatus/?ids={{item.id}}&status={{1-item.status}}" class="active ajax-get" data-toggle="class">
                                    <i class="fa fa-check text-success {%if item.status %}text-active{%else%}text{%endif%}">启用</i>
                                    <i class="fa fa-times text-danger {%if item.status %}text{%else%}text-active{%endif%}">停用</i>
                                    </a>
                            </td>
                        </tr>
                        {% else %}
                        <tr>
                            <td colspan="5">
                                <div class="alert alert-warning alert-block">
                                    <button data-dismiss="alert" class="close" type="button">×</button>
                                    <p>暂无数据</p>
                                </div>
                            </td>
                        </tr>
                        {% endfor %}
                    </tbody>
                </table>
            </div>
            <footer class="panel-footer">
                <div class="row">


                    <div class="col-sm-12 text-right text-center-xs">
                        {{pagerData | safe}}
                    </div>
                </div>
            </footer>
        </section>
    </section>
</section>

{% endblock %}
{% block script%}
<script src="/static/admin/js/parsley/parsley.min.js"></script>
<script src="/static/admin/js/parsley/parsley.extend.js"></script>
{% endblock%}